import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {

    return originalPush.call(this, location).catch(err => err)

}

Vue.use(VueRouter)

const routes = [{
        path: '/',
        redirect: '/login'

    },
    {
        path: '/login',
        name: 'Login',
        component: Login,
        meta: {
            isLogin: false
        }
    },
    {
        path: '/home',
        name: 'Home',
        meta: {
            title: '首页',
            isLogin: true,
            roles: ['test666', 'test888', 'test999', 'test333', 'admin1', 'myadmin', '2123', '']
        },
        component: () =>
            import ('../views/Home.vue'),
        children: [{
                path: '/cashier',
                name: 'Cashier',
                component: () =>
                    import ('../views/Cashier.vue'),
                meta: {
                    title: '收银',
                    isLogin: true,
                    roles: ['test666', 'test888', 'test999', 'test333', 'admin1', 'myadmin', '2123', '']
                },
            },
            // {
            //     path: '/oder/cashier',
            //     name: 'Cashiertwo',
            //     component: () =>
            //         import ('../views/Cashier.vue'),
            //     meta: {
            //         title: '收银',
            //         isLogin: true,
            //         roles: ['test666', 'test888', 'test999', 'test333', 'admin1', 'myadmin', '2123', '']
            //     },
            // },
            {
                path: '/index',
                name: 'index',
                component: () =>
                    import ('../views/index.vue'),
            },
            {
                path: '/commodity',
                name: 'Commodity',
                component: () =>
                    import ('../views/Commodity.vue'),
                meta: {
                    title: '菜品管理',
                    isLogin: true,
                    roles: ['test666', 'test888', 'test999', 'test333', 'admin1', 'myadmin', '2123', '']
                },
            },
            {
                path: '/member',
                name: 'Member',
                component: () =>
                    import ('../views/Member.vue'),
                meta: {
                    title: '会员管理',
                    isLogin: true,
                    roles: ['test666', 'test888', 'test999', 'test333', 'admin1', 'myadmin', '2123', '']
                },
            },
            // {
            //     path: '/oder/:id',
            //     name: 'Oder',
            //     component: () =>
            //         import ('../views/Oder.vue'),
            //     meta: {
            //         title: '点菜管理',
            //         isLogin: true,
            //         roles: ['test666', 'test888', 'test999', 'test333', 'admin1', 'myadmin', '2123', '']
            //     },
            // },
            {
                path: '/oder',
                name: 'Oder',
                component: () =>
                    import ('../views/Oder.vue'),
                meta: {
                    title: '点菜管理',
                    isLogin: true,
                    roles: ['test666', 'test888', 'test999', 'test333', 'admin1', 'myadmin', '2123', '']
                },
            },
            {
                path: '/personnel',
                name: 'Personnel',
                component: () =>
                    import ('../views/Personnel.vue'),
                meta: {
                    title: '人员管理',
                    isLogin: true,
                    roles: ['test666']
                },
            },
            {
                path: '/table',
                name: 'Table',
                component: () =>
                    import ('../views/Table.vue'),
                meta: {
                    title: '餐桌管理',
                    isLogin: true,
                    roles: ['test666', 'test888', 'test999', 'test333', 'admin1', 'myadmin', '2123', '']
                },
            },
        ]
    }
]

const router = new VueRouter({
    routes
})

export default router